/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cip.esymons.eventos.beans;

import java.util.ArrayList;
import java.util.List;
import javax.faces.model.SelectItem;
import org.cip.esymons.eventos.bc.ComiteLocalDelegate;
import org.cip.esymons.general.be.ComiteLocal;

/**
 *
 * @author OscarA
 */
public class ComiteLocalController {

    ComiteLocalDelegate delegate;
    List<ComiteLocal> listaComites;

    public ComiteLocalController() {
        delegate = new ComiteLocalDelegate();
        listaComites = new ArrayList<ComiteLocal>();
    }

    public ComiteLocalDelegate getDelegate() {
        return delegate;
    }

    public void setDelegate(ComiteLocalDelegate delegate) {
        this.delegate = delegate;
    }

    public SelectItem[] getComboComiteLocalxCD() {
        try {
            listaComites = delegate.listarXConsDepartamental(2);
            SelectItem[] comboComites = new SelectItem[listaComites.size()];
            for (int i = 0; i < listaComites.size(); i++) {
                comboComites[i] = new SelectItem(listaComites.get(i), listaComites.get(i).getCloNombre());
            }
            return comboComites;

        } catch (Exception e) {
            listaComites = new ArrayList<ComiteLocal>();
            SelectItem[] comboComites = new SelectItem[1];
            comboComites[0] = new SelectItem(new ComiteLocal(), "No hay Comites Locales");
            return comboComites;
        }

    }
}
